home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / database / hl / hl-1.002 / hl-1 / Include / EditForm.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-14  |  1.9 KB  |  96 lines

  1. /* -*- Mode: C -*- */
  2. /* EditForm.h - EditForm class - a form for editing
  3.  * Created by Robert Heller on Thu Dec 12 19:11:03 1991
  4.  *
  5.  * ------------------------------------------------------------------
  6.  * Home Libarian by Deepwoods Software
  7.  * Common Header Files
  8.  * ------------------------------------------------------------------
  9.  * Modification History:
  10.  * ------------------------------------------------------------------
  11.  * Contents:
  12.  * ------------------------------------------------------------------
  13.  * 
  14.  * 
  15.  * Copyright (c) 1991,1992 by Robert heller (D/B/A Deepwoods Software)
  16.  *        All Rights Reserved
  17.  * 
  18.  */
  19.  
  20. #ifndef _EDITFORM_
  21. #define _EDITFORM_
  22. #include <stream.h>
  23. #include <common.h>
  24. #include <ctype.h>
  25. #include <Terminal.h>
  26.  
  27. #ifdef OSK
  28. #define DEFAULTEDITOR "umacs"
  29. #endif
  30. #ifdef MESSYDOS
  31. #define DEFAULTEDITOR "edit"
  32. #endif
  33. #ifdef unix
  34. #define DEFAULTEDITOR "vi"
  35. #endif
  36.  
  37. typedef char* (*FieldToString)(void*);
  38. typedef void  (*StringToField)(char*,void*);
  39.  
  40. enum FieldType {Literal, String, EditorString,
  41.         Int, Float, Special };
  42.  
  43. struct Field {
  44.     void *fieldp;
  45.     FieldType type;
  46.     FieldToString ftos;
  47.     StringToField stof;
  48.     int row;
  49.     int col;
  50.     int width;
  51.     int height;
  52.     int buffersize;
  53. };
  54.  
  55. typedef void (*KeyFun)(EditForm&);
  56.  
  57. struct KeyBinding {
  58.     KeyFun fun;
  59.     char *docstring;
  60.     short int keycode;    
  61. };
  62.  
  63. class EditForm {
  64.     static char EditorCommand[48];
  65.     static Boolean EditorCmdInit;
  66.     char  Title[80];
  67.     Field *fields;
  68.     int   nFields;
  69.     KeyBinding *bindings;
  70.     int   nBinds;
  71.     int   currentField;
  72.     void HiliteField(int fieldno,Boolean hilite);
  73. public:
  74.     Boolean IsModified;
  75.         EditForm(char* title,int fieldcount,Field *infields,
  76.              int bindcount,KeyBinding *inbinds);
  77.            ~EditForm();
  78.     Boolean RunForm();
  79.     void RePaint();
  80.     void ResetField() {
  81.         currentField = 0;
  82.         for (int i = 0;i < nFields;i++) {
  83.             if (fields[i].type != Literal) {
  84.                 currentField = i+1;
  85.                 break;
  86.             }
  87.         }
  88.     }
  89.     int CurField() { return(currentField); }
  90.     friend class Terminal;
  91. };
  92.  
  93. #endif
  94.  
  95.  
  96.